#include <bits/stdc++.h>
using namespace std;

int total = 0;
int T[101];
int _root = 1;
string str[101];

void push(int k, int root = _root) {
    if (k < T[root]) {
        if (T[root * 2] == 0) T[root * 2] = k;
        else push(k, root * 2);
    }
    else {
        if (T[root * 2 + 1] == 0) T[root * 2 + 1] = k;
        else push(k, root * 2 + 1);
    }
}

int findUp(int node) {
    if (node == 1)   return -1;
    int up = node / 2;
    if (T[up * 2] == T[node])    return 0;
    else return 1;
}

void findRoot(int node) {
    int n = node;
    int c, last = findUp(n);
    for (int i = 0; i < str[node / 2].length() - 1; i++)
        str[node] += ".";
    n /= 2;
    while ((c = findUp(n)) != -1) {
        n /= 2;
        if (c != last) {
            str[node][str[n].length() - 1] = '|';
            last = c;
        }
    }
}

void processNode(int node) {
    if (node == 1) {
        str[node] = to_string(T[node]);
    }
    else {
        findRoot(node);
        str[node] += "|-" + to_string(T[node]);
    }
    if (T[node * 2] > 0 || T[node * 2 + 1] > 0)
        str[node] += "-|";
}

void processTree(int root = _root) {
    processNode(root);
    if (T[root * 2 + 1] > 0) {
        processTree(root * 2 + 1);
    }
    if (T[root * 2] > 0) {
        processTree(root * 2);
    }
}

void printTree(int root = _root) {
    if (T[root * 2 + 1] > 0)
        printTree(root * 2 + 1);
    cout << str[root] << endl;
    if (T[root * 2] > 0)
        printTree(root * 2);
}

int main() {
    int n = 0;
    cin >> n;
    T[_root] = n;
    char c = getchar();
    while (c != '\n') {
        cin >> n;
        push(n);
        c = getchar();
    }
    processTree();
    printTree();
    return 0;
}